﻿using System;
using System.Xml;
using DataScripter.Containers;

namespace DataScripter.XmlInterpreter.XmlInterpreters
{
    static class XmlInterpreterExtensions
    {
        public static void Register<T>(this IContainer engine, XmlElement element)
        {
            string typeDescriptor = element.GetAttribute("Type");
            string name = element.GetAttribute("Name");
            if (string.IsNullOrEmpty(name))
            {
                engine.RegisterType<T>(Type.GetType(typeDescriptor));
            }
            else
            {
                engine.RegisterType<T>(name, Type.GetType(typeDescriptor));
            }
        }

    }
}
